package com.remist.web.action;

import java.util.List;

import com.remist.model.User;
import com.remist.service.UserService;

public class UserAction extends BaseAction {
	private UserService userService;
	private List<User> users;
	private User userBean;
	public User getUserBean() {
		return userBean;
	}

	public void setUserBean(User userBean) {
		this.userBean = userBean;
	}

	public List<User> getUsers() {
		return users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	@Override
	public String execute() throws Exception {
		return super.execute();
	}
	
	public String userList() throws Exception {
		users = userService.getAllUser(0);
		return SUCCESS;
	}

	
	public String userAdd() throws Exception {
		if ( userBean !=null )
			userService.insertUser(userBean);
		return SUCCESS;
	}
	
	public String userDelete() throws Exception {
		if ( userBean !=null )
			userService.deleteUser(userBean);
		return SUCCESS;
	}
	
	public String userBeforeUpdate() throws Exception {
		if ( userBean !=null )
			userBean = userService.getUserById(userBean);
		return SUCCESS;
	}
	
	public String userUpdate() throws Exception {
		if ( userBean !=null )
			userService.updateUser(userBean);
		return SUCCESS;
	}
	
	
}
